﻿using System;
using System.Collections;
using System.Runtime.Serialization;
using System.Web;

namespace NWebMock
{
    public interface IHttpApplicationState : ICollection, ISerializable
    {
        #region Properties

        /// <summary>
        /// Gets the access keys in the HttpApplicationState collection.
        /// </summary>
        string[] AllKeys { get; }

        /// <summary>
        /// Gets a reference to the HttpApplicationState object.
        /// </summary>
        HttpApplicationState Contents { get; }

        /// <summary>
        /// Gets a single HttpApplicationState object by index.
        /// </summary>
        /// <param name="index">The numerical index of the object in the collection. </param>
        /// <returns>The object referenced by index.</returns>
        Object this[int index] { get; }

        /// <summary>
        /// Gets the value of a single HttpApplicationState object by name.
        /// </summary>
        /// <param name="name">The name of the object in the collection. </param>
        /// <returns>The object referenced by name.</returns>
        Object this[string name] { get; set; }

        /// <summary>
        /// Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance.
        /// </summary>
        ICollection Keys { get; }

        /// <summary>
        /// Gets all objects declared by an <object> tag where the scope is set to "Application" within the ASP.NET application.
        /// </summary>
        ICollection StaticObjects { get; }

        #endregion

        #region Methods

        /// <summary>
        /// Adds a new object to the HttpApplicationState collection.
        /// </summary>
        /// <param name="name">The name of the object to be added to the collection. </param>
        /// <param name="value">The value of the object. </param>
        void Add(string name, Object value);

        /// <summary>
        /// Removes all objects from an HttpApplicationState collection.
        /// </summary>
        void Clear();

        /// <summary>
        /// Gets an HttpApplicationState object by numerical index.
        /// </summary>
        /// <param name="index">The index of the application state object. </param>
        /// <returns>The object referenced by index.</returns>
        Object Get(int index);

        /// <summary>
        /// Gets an HttpApplicationState object by name.
        /// </summary>
        /// <param name="name">The name of the object. </param>
        /// <returns>The object referenced by name.</returns>
        Object Get(string name);

        /// <summary>
        /// Gets an HttpApplicationState object name by index.
        /// </summary>
        /// <param name="index">The index of the application state object. </param>
        /// <returns>The name under which the application state object was saved.</returns>
        string GetKey(int index);

        /// <summary>
        /// Locks access to an HttpApplicationState variable to facilitate access synchronization.
        /// </summary>
        void Lock();

        /// <summary>
        /// Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.
        /// </summary>
        /// <param name="sender">The source of the deserialization event.</param>
        void OnDeserialization(Object sender);

        /// <summary>
        /// Removes the named object from an HttpApplicationState collection.
        /// </summary>
        /// <param name="name">The name of the object to be removed from the collection. </param>
        void Remove(string name);

        /// <summary>
        /// Removes all objects from an HttpApplicationState collection.
        /// </summary>
        void RemoveAll();

        /// <summary>
        /// Removes an HttpApplicationState object from a collection by index.
        /// </summary>
        /// <param name="index">The position in the collection of the item to remove. </param>
        void RemoveAt(int index);

        /// <summary>
        /// Updates the value of an object in an HttpApplicationState collection.
        /// </summary>
        /// <param name="name">The name of the object to be updated. </param>
        /// <param name="value">The updated value of the object. </param>
        void Set(string name, Object value);

        /// <summary>
        /// Unlocks access to an HttpApplicationState variable to facilitate access synchronization.
        /// </summary>
        void UnLock();

        #endregion
    }
}
